<template>
    <view>
        <view>
            <uni-search-bar placeholder="搜索房源" @confirm="search()" v-model="searchValue">
                <uni-icons slot="searchIcon" color="#999999" size="18" type="home" />
            </uni-search-bar>
        </view>
        <view>
            
        </view>
        <view>
            <view class="uni-flex uni-row" v-for="(i,index) in rent" :key="index">
				<houseList v-bind:rent="i"></houseList>
            </view>
        </view>
    </view>
</template>

<script>
    import {UniSearchBar} from "@dcloudio/uni-ui"
    // import HMfilterDropdown from '@/components/HM-filterDropdown/ffff.vue';
    import houseList from "./houseList.vue"
    export default {
        name: "houseSelect",
        data(){
            return{
                searchValue:'',
                rent:[]
            }
        },
        methods:{
            search(){
            },
            getHouse(){
                this.$axios.post('getAllHouses')
                .then(res =>{
                this.house = res.data.allHouses
                })
            },
            getSell(){
                this.$axios.post('getAllRentings')
                .then(res =>{
                    this.rentingHouse = res.data.allRentings
                    for(let j=0 ; j < this.house.length ; j++){
                        for(let k=0 ; k < this.rentingHouse.length ; k++){
                            if(this.rentingHouse[k].houseId == this.house[j].houseId){
                                let temporary = {}
                                temporary.houseId = this.rentingHouse[k].houseId
                                temporary.rentingHeading = this.rentingHouse[k].rentingHeading
                                temporary.rentingPrice = this.rentingHouse[k].rentingPrice
                                temporary.houseEstate = this.house[j].houseEstate
                                temporary.houseArea = this.house[j].houseArea
                                temporary.houseSurfaceplot = this.house[j].houseSurfaceplot
                                temporary.houseDirection = this.house[j].houseDirection
                                temporary.houseRegion = this.house[j].houseRegion
                                temporary.houseCity = this.house[j].houseCity
                                this.rent.push(temporary)
                            }
                        } 
					}
                })
            }
        },
        onLoad(){
            this.getHouse()
            this.getSell()
        },
        components:{
            UniSearchBar,
           houseList
        }
    }
</script>

<style>

</style>
